<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是使用GitHub Action自动部署博客网站的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV04-GitHubAction-01-自动部署">
<meta property="og:url" content="https://sumumm.github.io/post/e7196653.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是使用GitHub Action自动部署博客网站的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions01.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions02.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions03.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions04.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions05.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions06.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions07.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions08.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/image-20230702164530840.png">
<meta property="og:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/image-20230702163618748.png">
<meta property="article:published_time" content="2023-07-02T08:17:07.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:57.074Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="博客搭建">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions01.png">


<link rel="canonical" href="https://sumumm.github.io/post/e7196653.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/e7196653.html","path":"post/e7196653.html","title":"LV04-GitHubAction-01-自动部署"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV04-GitHubAction-01-自动部署 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81Github-Actions%E4%BB%8B%E7%BB%8D"><span class="nav-text">一、Github Actions介绍</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E7%AE%80%E4%BB%8B"><span class="nav-text">1. 简介</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81Github-Actions%E4%BD%BF%E7%94%A8"><span class="nav-text">二、Github Actions使用</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E5%88%9B%E5%BB%BA%E4%BB%93%E5%BA%93"><span class="nav-text">1. 创建仓库</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E8%8E%B7%E5%8F%96Token"><span class="nav-text">2. 获取Token</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%9C%A8%E6%BA%90%E7%A0%81%E4%BB%93%E5%BA%93%E5%88%9B%E5%BB%BA%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="nav-text">3. 在源码仓库创建环境变量</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E5%88%9B%E5%BB%BAGithub-Actions%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-text">4. 创建Github Actions的配置文件</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#5-%E6%B7%BB%E5%8A%A0gulp%E5%8E%8B%E7%BC%A9%E5%8A%9F%E8%83%BD"><span class="nav-text">5. 添加gulp压缩功能</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#6-%E5%90%8C%E6%AD%A5%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2Gitee-Pages"><span class="nav-text">6. 同步自动部署Gitee Pages</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#6-1-%E6%B7%BB%E5%8A%A0%E7%A7%81%E9%92%A5%E5%92%8C%E5%AF%86%E7%A0%81"><span class="nav-text">6.1 添加私钥和密码</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-2-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6"><span class="nav-text">6.2 自动部署配置文件</span></a></li></ol></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/e7196653.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV04-GitHubAction-01-自动部署 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV04-GitHubAction-01-自动部署
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2023-07-02 16:17:07" itemprop="dateCreated datePublished" datetime="2023-07-02T16:17:07+08:00">2023-07-02</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" itemprop="url" rel="index"><span itemprop="name">博客搭建</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>3.1k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>11 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是使用GitHub Action自动部署博客网站的相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr><td align="center">参考方向  </td><td align="center">参考原文</td></tr>    <tr><td align="left">---</td><td align="left"><a href="" target="_blank">--- <i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">---</td>        <td align="left">--- <a href="" target="_blank">  <i class="fa fa-external-link-alt"></i></a></td>      </tr></table>
              </div>
            </details>

<p>在刚开始使用<code>Hexo</code>的时候安装的脚本、插件、引用的样式和文章等都比较少，编译部署起来就还好，时间也不长，但是当哪些越来越多的时候，编译时间也越来越久，而且<code>Gitee Pages</code>在仓库部署完毕后，还需要手动点击更新，才能完成页面的部署，不免就有些麻烦了，本文将介绍<code>Github</code>自带的自动部署工具<code>Github Actions</code>来实现静态网站的自动部署。</p>
<h1 id="一、Github-Actions介绍"><a href="#一、Github-Actions介绍" class="headerlink" title="一、Github Actions介绍"></a><font size=3>一、<code>Github Actions</code>介绍</font></h1><h2 id="1-简介"><a href="#1-简介" class="headerlink" title="1. 简介"></a><font size=3>1. 简介</font></h2><p><code>Github Actions</code>是<code>GitHub</code>于 2018 年 10 月推出的一个<code>CI/CD</code>服务。那什么是<code>CI/CD</code>呢？<code>CI/CD</code>其实说的是三件事情：</p>
<ul>
<li>持续集成（Continuous Integration）</li>
<li>持续交付（Continuous Delivery）</li>
<li>持续部署（Continuous Deployment）</li>
</ul>
<p>按照自己的理解，就是一个可以在<code>Github</code>仓库中自动执行一些命令的工具，它的配置文件为<code>yaml</code>格式。本文不是主要详细介绍它的语法，而是介绍如何使用这个工具来完成自动部署，所以这里就不写更多关于语法的啦（主要原因还是自己也不是特别了解😭），更多详细介绍可以查看官方介绍文档：<a href="https://docs.github.com/en/actions" target="_blank">Github Actions<i class="fa fa-external-link-alt"></i></a></p>
<h1 id="二、Github-Actions使用"><a href="#二、Github-Actions使用" class="headerlink" title="二、Github Actions使用"></a><font size=3>二、<code>Github Actions</code>使用</font></h1><details class="note info no-icon"><summary><p>点击查看参考教程和相关Github项目</p>
</summary>
<p>参考教程</p>
<table>
  <tr>
    <td align="center">博客名称</td>
    <td align="center">教程原帖</td>
  </tr>
  <tr>
    <td align="center">Akilar の糖果屋</td>
    <td align="left"><a href="https://akilar.top/posts/f752c86d/" target="_blank">使用 Github Action 实现全自动部署</a> </td>
  </tr>
  <tr>
    <td align="center">卓越科技的 Blog</td>
    <td align="left"><a href="https://blog.zykjofficial.top/posts/ea8e8e59/" target="_blank">使用 Github Actions 自动部署博客</a> </td>
  </tr>
</table>

<p>相关<code>Github</code>项目</p>
<table>
  <tr>
    <td align="center">项目说明</td>
    <td align="center">项目地址</td>
  </tr>
  <tr>
    <td align="center">镜像仓库</td>
    <td align="left"><a href="https://github.com/wearerequired/git-mirror-action" target="_blank">Git Mirror Action</a> </td>
  </tr>
  <tr>
    <td align="center">自动部署Gitee Pages</td>
    <td align="left"><a href="https://github.com/yanglbme/gitee-pages-action" target="_blank">Gitee Pages Action</a> </td>
  </tr>
</table>
</details>

<div class="note warning"><p>注意：若是直接复制以下代码，还请替换<code>[UserName]</code>为自己的<code>Github</code>或者<code>Gitee</code>名字，另外就是那些环境变量一定要在自己站点源码的<code>Secrets</code>中配置好。</p>
</div>

<h2 id="1-创建仓库"><a href="#1-创建仓库" class="headerlink" title="1. 创建仓库"></a><font size=3>1. 创建仓库</font></h2><p>在一切的一切开始之前肯定是需要一个仓库啦😄，我这里存放源码的是创建的私人仓库，这里就不写如何创建仓库、建立远程连接和上传源码了。</p>
<h2 id="2-获取Token"><a href="#2-获取Token" class="headerlink" title="2. 获取Token"></a><font size=3>2. 获取<code>Token</code></font></h2><p><code>Token</code>就是<code>Personal access tokens</code>，即私人访问令牌，看自己的源码仓库是放在<code>Github</code>还是其他平台了，我的是在<code>Github</code>上，<code>Gitee</code>作为镜像站，所以我只需要在<code>Github</code>上进行操作，这里简单记录一下如何在这两个平台获取<code>Token</code>的方式。</p>
<details class="note info no-icon"><summary><p>点击查看获取Token的步骤</p>
</summary>
<div class="tabs" id="first-unique-name"><ul class="nav-tabs"><li class="tab active"><a href="#first-unique-name-1">Github</a></li><li class="tab"><a href="#first-unique-name-2">Gitee</a></li></ul><div class="tab-content"><div class="tab-pane active" id="first-unique-name-1"><p>点击这里<a href="https://github.com/settings/tokens" target="_blank">【Github官网】&rarr;【右上角头像】&rarr;【Settings】&rarr;【Developer Settings】&rarr;【Personal access tokens】<i class="fa fa-external-link-alt"></i></a>打开<code>Personal access tokens</code>设置项。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions01.png" style="zoom: 33%;" >


<p>选择<code>generate new token</code>创建自己的私人访问令牌。<code>Note</code>也就是私人令牌的名称，随意命名就可以，不过要符合<code>Github</code>的要求，<code>Select scopes</code>中是选择私人访问令牌的权限，至少要勾选<code>repo</code>选项。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions02.png" style="zoom:43%;" >


<p>最后点击最下方的创建就可以生成自己的私人访问令牌啦，不过这个私人访问令牌只有创建的时候才会显示一次，后边是查看不了的，所以要注意记录下来。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions03.png" style="zoom:33%;" ></div><div class="tab-pane" id="first-unique-name-2"><p>点击这里<a href="https://gitee.com/profile/personal_access_tokens" target="_blank">【Gitee官网】&rarr;【右上角头像】&rarr;【设置】&rarr;【私人令牌】<i class="fa fa-external-link-alt"></i></a>，打开设置后下拉就可以找到【私人令牌】选项了，打开该设置项。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions04.png" style="zoom:33%;" >


<p>点击生成新令牌即可转到私人令牌创建界面，接下来是填写描述、勾选权限，由于是自己用的，所以我全部都勾选了。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions05.png" style="zoom:33%;" >


<p>最后点击提交，然后输入登录密码进行验证即可生成自己的私人令牌，<code>Gitee</code>的私人访问令牌也是只有创建的时候才会显示一次，后边是查看不了的，所以也要注意记录下来。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions06.png" style="zoom: 33%;"/></div></div></div>

</details>

<h2 id="3-在源码仓库创建环境变量"><a href="#3-在源码仓库创建环境变量" class="headerlink" title="3. 在源码仓库创建环境变量"></a><font size=3>3. 在源码仓库创建环境变量</font></h2><p>不想在文件中直接写私人令牌的话，可以在自己存放源码的仓库中添加环境变量：【Settings】&rarr;【Secrets】&rarr;【New repository secret】，在这里添加完之后，便可以在<code>Github Actions</code>的配置文件中通过<code>$&#123;&#123; secrets.[Environment secrets name] &#125;&#125;</code>来引用，更加的安全一些。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions07.png" style="zoom:33%;" />


<h2 id="4-创建Github-Actions的配置文件"><a href="#4-创建Github-Actions的配置文件" class="headerlink" title="4. 创建Github Actions的配置文件"></a><font size=3>4. 创建<code>Github Actions</code>的配置文件</font></h2><p>在站点<code>[blogRoot]</code>文件夹下也就是根目录下创建<code>.github/workflows</code>工作流程文件夹，一共创建2个文件夹<code>workflows</code>为<code>.github</code>的子文件夹，然后再工作流程文件夹下创建自动部署配置文件<code>autodeploy.yml</code>，名字任取，是<code>yml</code>格式文件即可。</p>
<details class="note info no-icon"><summary><p>点击查看自动部署配置文件内容</p>
</summary>
<figure class="highlight yaml"><figcaption><span>yaml [blogRoot]/.github/workflows/autodeploy.yml</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 当有改动推送到master分支时，启动Action</span></span><br><span class="line"><span class="attr">name:</span> <span class="string">自动部署</span></span><br><span class="line"></span><br><span class="line"><span class="attr">on:</span></span><br><span class="line">  <span class="attr">push:</span>             <span class="comment"># 有推送时就触发</span></span><br><span class="line">    <span class="attr">branches:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">master</span></span><br><span class="line"></span><br><span class="line">  <span class="attr">release:</span></span><br><span class="line">    <span class="attr">types:</span></span><br><span class="line">      <span class="bullet">-</span> <span class="string">published</span></span><br><span class="line"></span><br><span class="line"><span class="attr">jobs:</span></span><br><span class="line">  <span class="attr">deploy:</span></span><br><span class="line">    <span class="attr">runs-on:</span> <span class="string">ubuntu-latest</span></span><br><span class="line">    <span class="attr">steps:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">检查分支</span></span><br><span class="line">      <span class="attr">uses:</span> <span class="string">actions/checkout@v2</span></span><br><span class="line">      <span class="attr">with:</span></span><br><span class="line">        <span class="attr">ref:</span> <span class="string">master</span></span><br><span class="line"></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">安装</span> <span class="string">Node</span></span><br><span class="line">      <span class="attr">uses:</span> <span class="string">actions/setup-node@v1</span></span><br><span class="line">      <span class="attr">with:</span></span><br><span class="line">        <span class="attr">node-version:</span> <span class="string">&quot;12.x&quot;</span></span><br><span class="line"></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">安装</span> <span class="string">Hexo</span></span><br><span class="line">      <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">        export TZ=&#x27;Asia/Shanghai&#x27;</span></span><br><span class="line"><span class="string">        npm install hexo-cli -g</span></span><br><span class="line"><span class="string"></span></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">缓存</span> <span class="string">Hexo</span></span><br><span class="line">      <span class="attr">uses:</span> <span class="string">actions/cache@v1</span></span><br><span class="line">      <span class="attr">id:</span> <span class="string">cache</span></span><br><span class="line">      <span class="attr">with:</span></span><br><span class="line">        <span class="attr">path:</span> <span class="string">node_modules</span></span><br><span class="line">        <span class="attr">key:</span> <span class="string">$&#123;&#123;runner.OS&#125;&#125;-$&#123;&#123;hashFiles(&#x27;**/package-lock.json&#x27;)&#125;&#125;</span></span><br><span class="line"></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">安装依赖</span></span><br><span class="line">      <span class="attr">if:</span> <span class="string">steps.cache.outputs.cache-hit</span> <span class="type">!=</span> <span class="string">&#x27;true&#x27;</span></span><br><span class="line">      <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">        npm install --save</span></span><br><span class="line"><span class="string"></span>        </span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">生成静态文件</span></span><br><span class="line">      <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">        hexo clean</span></span><br><span class="line"><span class="string">        hexo generate</span></span><br><span class="line"><span class="string"></span>  </span><br><span class="line">    <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">部署Github</span></span><br><span class="line">      <span class="attr">env:</span></span><br><span class="line">        <span class="attr">TIME_ZONE:</span> <span class="string">Asia/Shanghai</span></span><br><span class="line">        <span class="comment"># 要部署的公共仓库</span></span><br><span class="line">        <span class="attr">DEPLOY_REPO:</span> [<span class="string">UserName</span>]<span class="string">/[UserName].github.io</span></span><br><span class="line">        <span class="comment"># 要部署的分支</span></span><br><span class="line">        <span class="attr">DEPLOY_BRANCH:</span> <span class="string">master</span></span><br><span class="line">        <span class="comment"># 在私人源码仓库的设置中设置私钥：[SourceRepo]--&gt;Settings--&gt;Setrets--&gt;Actions secrets</span></span><br><span class="line">        <span class="attr">GITHUB_PERSONAL_TOKEN:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.GITHUBPERSONALTOKEN</span> <span class="string">&#125;&#125;</span>  </span><br><span class="line">        <span class="attr">GITHUB_USER_NAME:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.GITHUBUSERNAME</span> <span class="string">&#125;&#125;</span></span><br><span class="line">        <span class="attr">GITHUB_USER_EMAIL:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.GITHUBUSEREMAIL</span> <span class="string">&#125;&#125;</span></span><br><span class="line">      <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">        cd ./public &amp;&amp; git init</span></span><br><span class="line"><span class="string">        git config user.name &quot;$GITHUB_USER_NAME&quot;</span></span><br><span class="line"><span class="string">        git config user.email &quot;$GITHUB_USER_EMAIL&quot;</span></span><br><span class="line"><span class="string">        git add .</span></span><br><span class="line"><span class="string">        git commit -m &quot;Automated Deployment By GitHub Actions @ $(date &#x27;+%Y-%m-%d %H:%M:%S&#x27;) $&#123;TIME_ZONE&#125;&quot;</span></span><br><span class="line"><span class="string"></span></span><br><span class="line">        <span class="comment"># --quiet: Suppress all output, including the listing of updated refs, unless an error occurs. Progress is not reported to the standard error stream.</span></span><br><span class="line">        <span class="string">git</span> <span class="string">push</span> <span class="string">--force</span> <span class="string">--quiet</span> <span class="string">&quot;https://$GITHUB_PERSONAL_TOKEN@github.com/$DEPLOY_REPO&quot;</span> <span class="string">master:$DEPLOY_BRANCH</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
</details>

<h2 id="5-添加gulp压缩功能"><a href="#5-添加gulp压缩功能" class="headerlink" title="5. 添加gulp压缩功能"></a><font size=3>5. 添加<code>gulp</code>压缩功能</font></h2><p>本地的时候有<code>gulp</code>压缩代码功能，自然也是可以实现<code>Github Actions</code>自动部署的时候进行静态压缩啦，在<code>autodeploy.yml</code>配置文件的<code>job</code>中<code>部署Github</code>之前添加以下内容，若是有报错之类的，可以将<code>安装gulp</code>相关内容移动到<code>安装依赖</code>之前。</p>
<figure class="highlight yaml"><figcaption><span>yaml [blogRoot]/.github/workflows/autodeploy.yml</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">安装gulp</span></span><br><span class="line">  <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line"><span class="string">    npm install gulp</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">gulp压缩站点文件</span></span><br><span class="line">  <span class="attr">run:</span> <span class="string">|</span></span><br><span class="line">    <span class="string">gulp</span></span><br></pre></td></tr></table></figure>

<h2 id="6-同步自动部署Gitee-Pages"><a href="#6-同步自动部署Gitee-Pages" class="headerlink" title="6. 同步自动部署Gitee Pages"></a><font size=3>6. 同步自动部署<code>Gitee Pages</code></font></h2><p>有大神编写了插件以便于实现<code>Gitee Pages</code>的自动部署，相关文章和相关的<code>Github</code>项目在文章开头已经说过，可以参考，另外仓库的说明文档中也写了具体的使用方法。</p>
<h3 id="6-1-添加私钥和密码"><a href="#6-1-添加私钥和密码" class="headerlink" title="6.1 添加私钥和密码"></a><font size=3>6.1 添加私钥和密码</font></h3><ul>
<li>第一步：添加个人私钥和Gtiee的登陆密码到站点私有仓库的环境变量中</li>
</ul>
<p>个人私钥和公钥都在<code>.ssh</code>文件夹内，私钥为<code>~/.ssh/id_rsa</code> 文件内，使用时将文件内所内容，包括<code>-----BEGIN RSA PRIVATE KEY-----</code>和<code>-----END RSA PRIVATE KEY-----</code>在内的全部内容都存放到变量值里。<code>Gitee</code>密码就是自己的登录密码。</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/003GithubActions08.png" style="zoom:33%;" />

<p>这里的私钥是哪里的私钥？应该是我们在上传源码的时候的设备中SSH相关目录下的私钥，需要注意的是GitHub和Gitee上要有相同的一个SSH公钥，仓库中的私钥要与公钥相配对：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/image-20230702164530840.png" alt="image-20230702164530840" style="zoom:50%;" />

<p>否则就可能出现下边的问题：</p>
<img data-src="https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/03%E6%88%91%E7%9A%84%E5%8D%9A%E5%AE%A2/LV04-GitHubAction-01-%E8%87%AA%E5%8A%A8%E9%83%A8%E7%BD%B2/img/image-20230702163618748.png" alt="image-20230702163618748" style="zoom: 33%;" />

<h3 id="6-2-自动部署配置文件"><a href="#6-2-自动部署配置文件" class="headerlink" title="6.2 自动部署配置文件"></a><font size=3>6.2 自动部署配置文件</font></h3><ul>
<li>第二步：修改自动部署配置文件</li>
</ul>
<p>在结尾添加以下内容：</p>
<figure class="highlight yaml"><figcaption><span>yaml [blogRoot]/.github/workflows/autodeploy.yml</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">同步到</span> <span class="string">Gitee</span></span><br><span class="line">  <span class="attr">uses:</span> <span class="string">wearerequired/git-mirror-action@master</span></span><br><span class="line">  <span class="attr">env:</span></span><br><span class="line">      <span class="comment"># 注意在私人源码仓库的设置中：[SourceRepo]--&gt;Settings--&gt;SetretsSettings-&gt;Secrets 配置 GITEE_RSA_PRIVATE_KEY</span></span><br><span class="line">      <span class="attr">SSH_PRIVATE_KEY:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.GITEE_RSA_PRIVATE_KEY</span> <span class="string">&#125;&#125;</span></span><br><span class="line">  <span class="attr">with:</span></span><br><span class="line">      <span class="comment"># 注意替换为自己的 GitHub 源仓库地址</span></span><br><span class="line">      <span class="attr">source-repo:</span> <span class="string">&quot;git@github.com:[UserName]/[UserName].github.io.git&quot;</span></span><br><span class="line">      <span class="comment"># 注意替换为自己的 Gitee 目标仓库地址</span></span><br><span class="line">      <span class="attr">destination-repo:</span> <span class="string">&quot;git@gitee.com:[UserName]/[UserName].git&quot;</span></span><br><span class="line"></span><br><span class="line">  <span class="comment"># 第一次需要手动部署Gitee Pages,而且登录地点会变成美国，将有一条警告邮件</span></span><br><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">构建</span> <span class="string">Gitee</span> <span class="string">Pages</span></span><br><span class="line">  <span class="attr">uses:</span> <span class="string">yanglbme/gitee-pages-action@master</span></span><br><span class="line">  <span class="attr">with:</span></span><br><span class="line">      <span class="comment"># 注意替换为自己的 Gitee 用户名</span></span><br><span class="line">      <span class="attr">gitee-username:</span> [<span class="string">UserName</span>]</span><br><span class="line">      <span class="comment"># 注意在私人源码仓库的设置中：[SourceRepo]--&gt;Settings--&gt;SetretsSettings-&gt;Secrets 配置 GITEE_PASSWORD</span></span><br><span class="line">      <span class="attr">gitee-password:</span> <span class="string">$&#123;&#123;</span> <span class="string">secrets.GITEE_PASSWORD</span> <span class="string">&#125;&#125;</span></span><br><span class="line">      <span class="comment"># 注意替换为自己的 Gitee 仓库</span></span><br><span class="line">      <span class="attr">gitee-repo:</span> [<span class="string">UserName</span>]<span class="string">/[UserName]</span></span><br><span class="line">      <span class="attr">branch:</span> <span class="string">master</span></span><br></pre></td></tr></table></figure>

<details class="note info no-icon"><summary><p>点击查看注意事项</p>
</summary>
<ul>
<li><code>Gitee</code>部署失败</li>
</ul>
<p>脚本的原理是用程序代替人工去点击<code>Gitee Pages</code>的更新按钮。所以需要先手动做一次页面部署，确保有那个更新按钮在，脚本才有生效的前提。</p>
<ul>
<li><code>Gitee</code>用<code>Github Actions</code>自动部署更新收到短信，提示异地登录需要验证码。</li>
</ul>
<p>因为<code>Github Actions</code>使用的是美国的服务器，所以，使用 <code>Github Actions</code>来远程更新<code>Gitee</code>的站点部署时，会收到异地登陆的短信，提示需要验证码。这个在脚本作者的<code>issues</code> 里有相应的解决方案：<a href="https://github.com/yanglbme/gitee-pages-action/issues/6" target="_blank">登陆失败 #6<i class="fa fa-external-link-alt"></i></a><br>我是直接之前绑定过微信的，所以每次只有异地登陆提醒，还没有收过验证码，如果之前没有绑定过的话，在微信上搜索<code>Gitee</code>微信公众号，可以在微信公众号内绑定自己的<code>Gitee</code>账号，这样虽然还是会有异地登录提示，但是发过来的消息不再需要填写验证码。</p>

</details>
    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/e7196653.html">LV04-GitHubAction-01-自动部署</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2023年07月02日 - 16:17</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/e7196653.html" title="LV04-GitHubAction-01-自动部署">https://sumumm.github.io/post/e7196653.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/%E5%8D%9A%E5%AE%A2%E6%90%AD%E5%BB%BA/" rel="tag"><i class="fa fa-tag"></i> 博客搭建</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/c5b8cba6.html" rel="prev" title="LV05-部署云服务器-01-登录服务器">
                  <i class="fa fa-angle-left"></i> LV05-部署云服务器-01-登录服务器
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/704415cc.html" rel="next" title="LV03-Markdown-03-图片">
                  LV03-Markdown-03-图片 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">false</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
